<?php
/**
 * @file indigo/framework/includes/webstart.php
 *
 * This file defines the basic "boot" process of the Indigo framework. Loads helper functions
 * found in functions.php and the Autoloader class.
 *
 * Peforms initial security measures by emulating register_globals = Off if it is On
 *
 * If the Config file was instantiated successfully, it sets the timezone of the
 * current script and attempts to instantiate the Database class.
 * Else, the installation scripts are run
 */
  namespace indigo\framework;
  use Exception;
  
  if(!defined('INDIGO'))
    exit;

  error_reporting(E_ALL ^ E_NOTICE);

  require_once 'functions.php';
  require_once 'framework/classes/Autoloader.php';
  
  deregisterGlobals();
  
  global $usConfig, $usDatabase;
  
  $usConfig = Config::load();

  if ($usConfig) {
    date_default_timezone_set($usConfig->timezone);
    
    try {
      $usDatabase = new Database($usConfig);
    } catch (Exception $e) {
      echo $e->getMessage();
      exit;
    }
  } else {
    die('Config file not found!');
  }